package com.augurit.gzcgwsp.csdlwj.convert;

import java.util.ArrayList;
import java.util.List;

import org.dozer.DozerBeanMapper;

import com.augurit.gzcgwsp.csdlwj.entity.YwComQyxxCsdlwj;
import com.augurit.gzcgwsp.csdlwj.web.form.YwComQyxxCsdlwjForm;
import com.augurit.gzcgwsp.ywcmn.entity.YwComQyxx;


public class YwComQyxxCsdlwjConvertor {
	public static YwComQyxxCsdlwjForm convertVoToForm(YwComQyxxCsdlwj entity) {
		if (entity == null) return null;
		
		return new DozerBeanMapper().map(entity, YwComQyxxCsdlwjForm.class);
	}
	
	public static void convertFormToVo(YwComQyxxCsdlwjForm form, YwComQyxxCsdlwj entity) {
		if(form.getId() != null)
			entity.setId(form.getId());
		if(form.getJsdw() != null && form.getJsdw().trim().length() > 0)
			entity.setJsdw(form.getJsdw());
		if(form.getJsdwAddress() != null && form.getJsdwAddress().trim().length() > 0)
			entity.setJsdwAddress(form.getJsdwAddress());
		if(form.getJsdwTel() != null && form.getJsdwTel().trim().length() > 0)
			entity.setJsdwTel(form.getJsdwTel());
		if(form.getFddbr() != null && form.getFddbr().trim().length() > 0)
			entity.setFddbr(form.getFddbr());
		if(form.getFddbrLxr() != null && form.getFddbrLxr().trim().length() > 0)
			entity.setFddbrLxr(form.getFddbrLxr());
		if(form.getJsdwSzq() != null && form.getJsdwSzq().trim().length() > 0)
			entity.setJsdwSzq(form.getJsdwSzq());
		
		
	}
	
	public static List<YwComQyxxCsdlwjForm> convertVoListToFormList(List<YwComQyxxCsdlwj> ywComQyxxCsdlwjList) {
		if(ywComQyxxCsdlwjList != null && ywComQyxxCsdlwjList.size() > 0) {
			List<YwComQyxxCsdlwjForm> YwComQyxxCsdlwjFormList = new ArrayList<YwComQyxxCsdlwjForm>();
			for(int i=0; i<ywComQyxxCsdlwjList.size(); i++) {
				YwComQyxxCsdlwjFormList.add(convertVoToForm(ywComQyxxCsdlwjList.get(i)));
			}
			return YwComQyxxCsdlwjFormList;
		}
		return null;
	}
	
	public static List<YwComQyxxCsdlwj> convertFormListToVoList(List<YwComQyxxCsdlwjForm> YwComQyxxCsdlwjFormList) {
		if(YwComQyxxCsdlwjFormList != null && YwComQyxxCsdlwjFormList.size() > 0) {
			List<YwComQyxxCsdlwj> ywComQyxxCsdlwjList = new ArrayList<YwComQyxxCsdlwj>();
			for(int i=0; i<YwComQyxxCsdlwjFormList.size(); i++) {
				YwComQyxxCsdlwj ywComQyxxCsdlwj = new YwComQyxxCsdlwj();
				convertFormToVo(YwComQyxxCsdlwjFormList.get(i), ywComQyxxCsdlwj);
				ywComQyxxCsdlwjList.add(ywComQyxxCsdlwj);
			}
			return ywComQyxxCsdlwjList;
		}
		return null;
	}
}